package com.ruoyi.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.domain.ApplicationRecord;
import com.ruoyi.service.IApplicationRecordService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * ApplicationRecordController
 * 
 * @author ruoyi
 * @date 2025-01-11
 */
@RestController
@RequestMapping("/applicationRecord")
public class ApplicationRecordController extends BaseController
{
    @Autowired
    private IApplicationRecordService applicationRecordService;

    /**
     * 查询ApplicationRecord列表
     */
    @RequiresPermissions("applicationRecord:applicationRecord:list")
    @GetMapping("/list")
    public TableDataInfo list(ApplicationRecord applicationRecord)
    {
        startPage();
        List<ApplicationRecord> list = applicationRecordService.selectApplicationRecordList(applicationRecord);
        return getDataTable(list);
    }

    /**
     * 导出ApplicationRecord列表
     */
    @RequiresPermissions("applicationRecord:applicationRecord:export")
    @Log(title = "ApplicationRecord", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ApplicationRecord applicationRecord)
    {
        List<ApplicationRecord> list = applicationRecordService.selectApplicationRecordList(applicationRecord);
        ExcelUtil<ApplicationRecord> util = new ExcelUtil<ApplicationRecord>(ApplicationRecord.class);
        util.exportExcel(response, list, "ApplicationRecord数据");
    }

    /**
     * 获取ApplicationRecord详细信息
     */
    @RequiresPermissions("applicationRecord:applicationRecord:query")
    @GetMapping(value = "/{applicationId}")
    public AjaxResult getInfo(@PathVariable("applicationId") Long applicationId)
    {
        return success(applicationRecordService.selectApplicationRecordByApplicationId(applicationId));
    }

    /**
     * 新增ApplicationRecord
     */
    @RequiresPermissions("applicationRecord:applicationRecord:add")
    @Log(title = "ApplicationRecord", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ApplicationRecord applicationRecord)
    {
        return toAjax(applicationRecordService.insertApplicationRecord(applicationRecord));
    }

    /**
     * 修改ApplicationRecord
     */
    @RequiresPermissions("applicationRecord:applicationRecord:edit")
    @Log(title = "ApplicationRecord", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ApplicationRecord applicationRecord)
    {
        return toAjax(applicationRecordService.updateApplicationRecord(applicationRecord));
    }

    /**
     * 删除ApplicationRecord
     */
    @RequiresPermissions("applicationRecord:applicationRecord:remove")
    @Log(title = "ApplicationRecord", businessType = BusinessType.DELETE)
	@DeleteMapping("/{applicationIds}")
    public AjaxResult remove(@PathVariable Long[] applicationIds)
    {
        return toAjax(applicationRecordService.deleteApplicationRecordByApplicationIds(applicationIds));
    }
}
